<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text">
    <div style="width: 100px;height: 100px;background-color: pink;">

    </div>
    <script>
        const inp = document.querySelector('input');
        //事件绑定的第一个参数就是事件对象 event ev e
        //常用属性 type clientX/Y offsetX/Y key
        //
        inp.addEventListener('keyup', function (e) {
            //事件对象
            console.log(e);
            //key键值
            if (e.key === 'Enter') {
                console.log('发表成功');
            }
            // type 事件类型
            console.log(e.type);
        })
        const box = document.querySelector('div');
        box.addEventListener('mouseenter', function (e) {
            console.log(`横坐标：${e.clientX}纵坐标：${e.clientY}`);
        })
    </script>
</body>

</html>